import { lazy } from 'react';

import { RoutesType } from '@customTypes/customTypes';

import loggedInRoutes from './loggedInRoutes';
import testRoutes from '../test/routes';

const routes: RoutesType[] = [
  {
    component: lazy((): Promise<any> => import('@layouts/BasicLayout')), // 基础样式
    children: [
      {
        path: '/oauth',
        component: lazy((): Promise<any> => import('@layouts/OauthLayout')), // 登陆注册通用样式
        children: [
          {
            path: 'login',
            name: '登录',
            component: lazy((): Promise<any> => import('@rootPages/Login'))
          },
          {
            path: 'find-password',
            name: '忘记密码',
            component: lazy((): Promise<any> => import('@rootPages/FindPassword'))
          }
        ]
      },
      {
        component: lazy((): Promise<any> => import('@layouts/SecurityLayout')), // 鉴权跳转样式
        children: [
          {
            component: lazy((): Promise<any> => import('@layouts/MenuLayout')), // 菜单栏样式
            children: [
              {
                path: '/',
                index: true,
                name: '工作区',
                component: lazy((): Promise<any> => import('@components/HomePage')) // 登陆后主界面
              },
              ...loggedInRoutes,
              {
                path: '*',
                name: '404',
                component: lazy((): Promise<any> => import('@components/ErrorPage'))
              }
            ]
          }
        ]
      },
      {
        path: '/un-authorization',
        name: '未认证',
        component: lazy((): Promise<any> => import('@components/UnAuthorizationPage'))
      },
      ...testRoutes
    ]
  }
];

export default routes;
